//
//  UIViewController+Extension.m
//  Bigeyes
//
//  Created by 红沙尘 on 17/4/17.
//  Copyright © 2017年 红沙尘. All rights reserved.
//

#import "UIViewController+Extension.h"

@implementation UIViewController (Extension)

- (void)setTitleText:(NSString *)titleText {
    
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 150, 40)];
    titleLabel.font = [UIFont systemFontOfSize:17];
    titleLabel.textColor = [UIColor colorWithHexString:@"#202020"];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.text = titleText;
    titleLabel.backgroundColor = [UIColor clearColor];
    
    self.navigationItem.titleView = titleLabel;
}

- (void)setTitleText:(NSString *)titleText style:(TitleType)style{
    
    NSArray *array = @[[UIColor colorWithHexString:@"#202020"],
                       [UIColor blackColor],
                       [UIColor whiteColor],];
    
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 150, 40)];
    titleLabel.font = [UIFont systemFontOfSize:17];
    titleLabel.textColor = array[style];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.text = titleText;
    titleLabel.backgroundColor = [UIColor clearColor];
    
    self.navigationItem.titleView = titleLabel;
}

- (UIToolbar *)toolbarView
{
    UIToolbar *bar  = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 40)];
    
    CGFloat w = bar.frame.size.height;
    
    UIButton *closeBtn = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth - w, 0, w,w)];
    closeBtn.titleLabel.font = [UIFont systemFontOfSize:14.0f];
    [closeBtn setTitle:@"收起" forState:UIControlStateNormal];
    [closeBtn setTitleColor:ARGB(0, 122, 255, 1) forState:UIControlStateNormal];
    [closeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
    [closeBtn addTarget:self
                 action:@selector(closeKeyboard)
       forControlEvents:UIControlEventTouchUpInside];
    [bar addSubview:closeBtn];
    
    return bar;
}

- (void)closeKeyboard
{
    
}

@end
